


        var headSwp = new Swiper('.headSwp',{
            loop:true,
            autoplay:{
                disableOnInteraction: false,
            },
            pagination: {
                el: '.swiper-pagination',
                clickable:true,
            }
        })

        var advSwp = new Swiper('.advSwp',{
            slidesPerView:'auto',
            spaceBetween:40,
            breakpoints:{
                1200:{
                    spaceBetween:25,
                },
                767:{
                    spaceBetween:10,
                }
            }
        })

        var clicked = false;
        var watchStore = null;
        var sizeW = 545;
        var storeBtwn = 20;
        var storeCurr = 0;
        var storeLength = Math.floor($('main #store .swiper .storeSwp .item').length / 2) * 2 - 1;
        storeLength < 0 && (storeLength = 0);
        var storeMovePrevent = false;
        var prevClick = false;
        var scrollInt = null;
        var scrollingPrevent = false;
        function scrollSec(val){
            console.log(val);
            scrollingPrevent = true;    
            scrollInt = setInterval(function(){
                var now = document.documentElement.scrollTop || document.body.scrollTop;
                now = parseInt(now);
                if(now > val){
                    var v = Math.ceil((now - val) / 15);
                    now -= v;
                }else if(now < val){
                    var v = Math.ceil((val - now) / 15);
                    now += v;
                }
                document.documentElement.scrollTop = document.body.scrollTop = now;
               
                if(now == val){
                    scrollingPrevent = false;
                    clearInterval(scrollInt);
                }
            },10)
        }

        $(document).ready(function(){
            $('main #contact .agree i').click(function(){
                clicked = !clicked;
                console.log(clicked);
                if(clicked){
                    $(this).addClass('clicked');
                }else{
                    $(this).removeClass('clicked');
                }
            })

            $('main .adv .swiper .btn').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    advSwp.slidePrev();
                }else{
                    advSwp.slideNext();
                }
            })

            $('main #store .swiper .btn').click(function(){
                if($(this)[0].className.indexOf('prev') >= 0){
                    prevClick = true;
                    storeMovePrevent = false;
                    /*if($('main #store .swiper .storeSwp .item')[0].getBoundingClientRect().left < window.innerWidth){
                        storeMovePrevent = true;
                    }else{
                        storeMovePrevent = false;
                    }*/
                    if(storeCurr == 0) return false;
                    /*if(storeCurr > 1){
                        storeCurr -= 2;
                    }else{
                        storeCurr--;
                    }*/
                    storeCurr--;
                }else{
                    prevClick = false;
                    if(storeMovePrevent) return false;
                    if(storeCurr * 2 - 1 == storeLength) return false;
                    /*if(storeCurr >= 1){
                        storeCurr += 2;
                    }else{
                        storeCurr++;
                    }*/
                    storeCurr++;
                    if($('main #store .swiper .storeSwp .item:last-child')[0].getBoundingClientRect().left < window.innerWidth){
                        storeMovePrevent = true;
                    }
                    //console.log(storeCurr);
                }
                
                
            })

            watchStore = setInterval(function(){
                
                var reactSizeW = sizeW;
                var reactBtwn = storeBtwn;
                if(window.innerWidth <= 767){
                    reactSizeW = 200;
                    reactBtwn = 10;
                }else if(window.innerWidth <= 1000){
                    reactSizeW = 300;
                }else if(window.innerWidth <= 1200){
                    reactSizeW = 360;
                }else if(window.innerWidth <= 1650){
                    reactSizeW = 420;
                }else if(window.innerWidth <= 1750){
                    reactSizeW = 500;
                }
                for(var i = 1;i < $("main #store .swiper .storeSwp .item").length;i++){
                    if(i % 2 == 0){
                        continue;
                    }
                    var left = Math.floor(i / 2) * reactSizeW + $("main #store .swiper .storeSwp .item")[0].offsetWidth + Math.ceil(i / 2) * reactBtwn;
                    $('main #store .swiper .storeSwp .item').eq(i).css('left',(left + 'px'));
                    if(i + 1 != $('main #store .swiper .storeSwp .item').length){
                        $('main #store .swiper .storeSwp .item').eq(i + 1).css('left',(left + 'px'));
                    }
                }
                if($('.mobileDevice').length) return false;
                if(storeMovePrevent){
                    if(prevClick){

                    }else{
                        if($('main #store .swiper .storeSwp .item:last-child')[0].getBoundingClientRect().left + $('main #store .swiper .storeSwp .item:last-child')[0].offsetWidth != window.innerWidth){
                            var moveLft = $('main #store .swiper .storeSwp .item:last-child')[0].offsetLeft + $('main #store .swiper .storeSwp .item:last-child')[0].offsetWidth - $('main #store .swiper .storeSwp')[0].offsetWidth;
                            $('main #store .swiper .storeSwp .palace')[0].style.transform = 'translateX(-' + moveLft + 'px)';
                        }
                    }
                }else{
                    if(!storeCurr){
                        $('main #store .swiper .storeSwp .palace').css('transform','translateX(0px)');
                    }else{
                        var palaceLft = reactSizeW * (storeCurr - 1) + $("main #store .swiper .storeSwp .item")[0].offsetWidth + storeCurr * reactBtwn;
                        $('main #store .swiper .storeSwp .palace')[0].style.transform = 'translateX(-' + palaceLft + 'px)';
                    }
                }
                
                
            },10)

            watchBrowse = setInterval(function(){
                
                //var navTop = $('header')[0].getBoundingClientRect().top + $('header')[0].offsetHeight;4
                if($('header')[0].className.indexOf('hidden') >= 0){
                    $('main .toTop').addClass('show');
                }else{
                    $('main .toTop').removeClass('show');
                }
                var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
                var headerH = $('header')[0].offsetHeight;
                if($('.mobileDevice').length){
                    if(scrollTop > window.innerWidth - headerH / 2 - 20){
                        $('header').addClass('hidden');
                    }else{
                        $('header').removeClass('hidden');
                        if(!scrollingPrevent){
                            $('header').removeClass('appear');
                        }
                    }
                }else{
                    if(scrollTop > window.innerWidth - headerH / 2 - 20){
                        $('header').addClass('hidden pc');
                    }else{
                        $('header').removeClass('hidden pc');
                    }
                }
                
            },10)

            $('header nav .menuBtn').click(function(){
                if($('.mobileDevice').length){
                    if($(this).parents('header')[0].className.indexOf('appear') >= 0){
                        $(this).parents('header').removeClass('appear');
                    }else{
                        $(this).parents('header').addClass('appear');
                    }
                    
                }
            })
            $('header nav .menuBtn').mouseenter(function(){
                if(!$('.mobileDevice').length){
                    console.log('c');
                    $(this).parents('header').addClass('appear');
                }
            })
            $('header').mouseleave(function(){
                if(!$('.mobileDevice').length){
                    $(this).removeClass('appear');
                }
            })
            $('header nav a').click(function(){
                if(!$(this).index()){
                    $('main .toTop')[0].click();
                }else{
                    if($('header')[0].className.indexOf('hidden') < 0){
                        $('header').addClass('appear');    
                    }
                    
                    var point = $($(this).attr('data-go'))[0].offsetTop - $('header')[0].offsetHeight - 20;
                    scrollSec(point);
                }
            })

            $('main .question .inner .ask').click(function(){
                $('header nav a:last-child')[0].click();
            })
        })